home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / 3d_lib.zip / TRANS.C < prev    next >
C/C++ Source or Header  |  1990-12-09  |  1KB  |  47 lines

  1. /* Add translation to transformation matrix
  2.  
  3.    Copyright (c) 1988 by Gus O'Donnell
  4.  
  5.    Revision history:
  6.  
  7.    Version 1.00         February 29, 1988       As released.
  8.  
  9.    Version 1.01         March 20, 1988          Created libraries for all
  10.                                                 memory models
  11.  
  12. */
  13. #include "3d.h"
  14. #include <float.h>
  15. #include <math.h>
  16. #include <stdio.h>
  17.  
  18. void    trans (double tx, double ty, double tz, MATRIX this_mat)
  19.  
  20. /* Add translation to the transformation matrix.
  21.  
  22. Vertices may be translated in any direction, given by [tx ty tz].  The
  23. result of the transformation is
  24.  
  25.           [x y z] -> [(x + tx) (y + ty) (z + tz)]
  26.  
  27. The matrix created for the translation transformation is
  28.  
  29.            |  1.0  0.0  0.0  0.0  |
  30.            |  0.0  1.0  0.0  0.0  |
  31.            |  0.0  0.0  1.0  0.0  |
  32.            |  tx   ty   yz   1.0  |
  33.  
  34. The current transformation matrix this_mat is then multiplied by the trans-
  35. lation transformation matrix, thus concatenating the translation operation
  36. with the current transformation.
  37. */
  38. {
  39.     MATRIX t_mat;
  40.  
  41.     identity (t_mat);
  42.     t_mat [3] [0] = tx;
  43.     t_mat [3] [1] = ty;
  44.     t_mat [3] [2] = tz;
  45.     mat_mul (this_mat,t_mat,this_mat);
  46. }
  47.